'use strict'
const Koa=require('koa')
const bodyParser=require('koa-bodyparser')
const cors=require('koa-cors')
const routerMiddle=require('./router/index')
const {Products,sync} = require('./model/index')

sync().then(()=>{
    Products.bulkCreate([
            {
              productName: 'iPhone 13 Pro 256G 远峰蓝',
              price: 8399,
              stockNum: 500,
              supplire: 'Apple'
            },
            {
              productName: '小苹果',
              price: 5.9,
              stockNum: 50000,
              supplire: 'Apple'
            }
          ])
})

let app=new Koa()

app.use(cors())
app.use(bodyParser())
app.use(routerMiddle())


let port=3000
app.listen(port)
console.log(`http://localhost:${port}`);